package com.javen.services;

import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.javen.mapper.UserMapper;
import com.javen.pojo.User;

@Service
public class UserServiceImpl {
    @Autowired 
    private UserMapper userMapper;
    
	  public Map<String, Object> login(String account, String password) {
			int errorCode = 0;
	  	String error  = "";
	  	String returnContent = "";
	  	try {
	  				
	  		List<User> resulT = new ArrayList<User>();	
	  		resulT = userMapper.selectByAccountAndPassword(account, password);
			  if (resulT.size() == 0) {
				  errorCode = -1;
				  error = "该账户不存在,请检查账户或密码是否正确"; 
			  }else {
				error = "";
			  }	
			  
			} catch (Exception e) {
				// TODO: handle exception
				errorCode = -100;
				error     = "请求失败";
			}
	  	
	  	Map<String, Object> map = new HashMap<String, Object>();
	  	map.put("errorCode", errorCode);
	  	map.put("error", error);
	  	map.put("returnContent", returnContent);
	  	return map;
	 }
    
}
